package com.cust.cow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cust.cow.common.BullCollectSemenLog;
import com.cust.cow.common.Result;
import com.cust.cow.pojo.bullCattle;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@Mapper
public interface BullCattleMapper extends BaseMapper<bullCattle> {
    @Select("select * from bullCattle")
    public List<bullCattle> findBullCattleAll();

    @Insert("insert into bullCattle values(#{cattleId},#{collectSemenNumber})")
    public int insertBullCattle(@RequestBody bullCattle bullCattle);

    @Delete("delete from bullCattle where cattle_id = #{cattleId}")
    public int deleteBullCattle(Integer cattleId);

    @Select("select c.cattle_id, c.breed_id, c.birthday, c.weight, c.sex,  m.collect_semen_date,  cc.collect_semen_number,     c.quarantine_situation, c.remark from bull_cattle cc, collect_semen_log m, cattle c where cc.cattle_id = m.cattle_id and cc.cattle_id = c.cattle_id and c.cattle_id = #{cattleId}")
    public BullCollectSemenLog findBullCattleById(Integer cattleId);

    @Select("select c.cattle_id, c.breed_id, c.birthday, c.weight, c.sex,  m.collect_semen_date,  cc.collect_semen_number,     c.quarantine_situation, c.remark from bull_cattle cc, collect_semen_log m, cattle c where cc.cattle_id = m.cattle_id and cc.cattle_id = c.cattle_id")
    public List<BullCollectSemenLog> findBullCattleCs();

}
